package com.kingsoft.dc.khaos.plugin.core.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by jing on 19/7/22.
 */
public class Logging {
    private Logger log_ = null;

    protected String logName(){
        String className = this.getClass().getName();
        int index = className.lastIndexOf(".");
        return className.substring(index + 1);
    }

    protected Logger log() {
        if(log_ == null){
            log_ = LoggerFactory.getLogger(logName());
        }
        return log_;
    }

    protected void logInfo(String msg) {
        if(log().isInfoEnabled()) {
            log().info(msg);
        }
    }

    protected void logDebug(String msg) {
        if(log().isDebugEnabled()) {
            log().debug(msg);
        }
    }

    protected void logTrace(String msg) {
        if(log().isTraceEnabled()) {
            log().trace(msg);
        }
    }

    protected void logWarning(String msg) {
        if(log().isWarnEnabled()) {
            log().warn(msg);
        }
    }

    protected void logError(String msg) {
        if(log().isErrorEnabled()) {
            log().error(msg);
        }
    }



}
